package com.async.designpatterns.create.afactory;

import com.async.designpatterns.create.factory.Sender;
import com.async.designpatterns.create.factory.SmsSender;

/**
 * Created by wenzhuo on 2018/1/1.
 */
public class SmsSenderFactory implements Provider {

    @Override
    public Sender produce() {
        System.out.println("实时创建SMS Sender");
        return new SmsSender();
    }

    @Override
    public Sender delayProduce() {
        try{
            //延迟1秒
            System.out.println("创建SMS Sender");
            Thread.sleep(1000);
            System.out.println("创建SMS Sender 完成！");
        } catch (Exception ex){
            return null;
        }

        return new SmsSender();
    }

}
